]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
extensions: Consistently handle createExtensionObject() errors
authorFlorian Müllner <fmuellner@gnome.org>
Wed, 17 May 2017 21:51:49 +0000 (23:51 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Mon, 17 Jul 2017 11:00:00 +0000 (13:00 +0200)
The method may throw an error, for example when metadata.json is
missing or cannot be parsed, however we are currently not always
handling it.

https://bugzilla.gnome.org/show_bug.cgi?id=781728

js/ui/extensionDownloader.js
js/ui/extensionSystem.js

index 6fa06279a2cbef638797ee2a94ee2bfc60d31756..452a83a4d5687b3a19022011bb00b8e28de2c929 100644 (file)
@@ -130,12 +130,14 @@ function updateExtension(uuid) {
             FileUtils.recursivelyMoveDir(extensionDir, oldExtensionTmpDir);
             FileUtils.recursivelyMoveDir(newExtensionTmpDir, extensionDir);
 
-            let extension = ExtensionUtils.createExtensionObject(uuid, extensionDir, ExtensionUtils.ExtensionType.PER_USER);
+            let extension = null;
 
             try {
+                extension = ExtensionUtils.createExtensionObject(uuid, extensionDir, ExtensionUtils.ExtensionType.PER_USER);
                 ExtensionSystem.loadExtension(extension);
             } catch(e) {
-                ExtensionSystem.unloadExtension(extension);
+                if (extension)
+                    ExtensionSystem.unloadExtension(extension);
 
                 logError(e, 'Error loading extension %s'.format(uuid));
 
@@ -242,9 +244,8 @@ const InstallExtensionDialog = new Lang.Class({
                 global.settings.set_strv(ExtensionSystem.ENABLED_EXTENSIONS_KEY, enabledExtensions);
             }
 
-            let extension = ExtensionUtils.createExtensionObject(uuid, dir, ExtensionUtils.ExtensionType.PER_USER);
-
             try {
+                let extension = ExtensionUtils.createExtensionObject(uuid, dir, ExtensionUtils.ExtensionType.PER_USER);
                 ExtensionSystem.loadExtension(extension);
             } catch(e) {
                 uninstallExtension(uuid);
index a4dc29eeab7efd6929bc9751b364376ecd91d2be..fc359e6ace3438a4d1a3404c65129c555c412edd 100644 (file)
@@ -199,7 +199,14 @@ function reloadExtension(oldExtension) {
     unloadExtension(oldExtension);
 
     // Now, recreate the extension and load it.
-    let newExtension = ExtensionUtils.createExtensionObject(uuid, dir, type);
+    let newExtension;
+    try {
+        newExtension = ExtensionUtils.createExtensionObject(uuid, dir, type);
+    } catch(e) {
+        logExtensionError(uuid, e);
+        return;
+    }
+
     loadExtension(newExtension);
 }